﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
using Fayson.BO;

namespace Fayson
{
    public class NHibernateHelper
    {
        private static ISessionFactory m_SessionFactory;
        //private static Configuration m_Cfg;

        private static ISessionFactory SessionFactory
        {
            get
            {
                if (m_SessionFactory == null)
                {
                    var configuration = new Configuration();
                    configuration.Configure();
                    configuration.AddAssembly(typeof(VAType).Assembly);
                    m_SessionFactory = configuration.BuildSessionFactory();
                }
                return m_SessionFactory;
            }
        }

        public static ISession OpenSession()
        {
            return SessionFactory.OpenSession();
        }

    }
}
